package com.neuedu.controller;

import com.alibaba.fastjson2.JSON;
import com.neuedu.entity.Admin;
import com.neuedu.service.AdminService;
import com.neuedu.service.impl.AdminServiceImpl;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

import java.sql.Date;
import java.sql.Time;
import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminController {
    AdminService adminService = new AdminServiceImpl();
    @GetMapping("/list")
    public List<Admin> list() {
        return adminService.list();
    }
    @PostMapping("/add")
    public boolean add(Admin admin) {
        admin.setCreateDate(new Date(System.currentTimeMillis()));
        admin.setCreateTime(new Time(System.currentTimeMillis()));
        admin.setPassword("123456");
        return adminService.add(admin);
    }
    @GetMapping("/getById")
    public Admin getById(Integer id) {
        return adminService.getById(id);
    }
    @PostMapping("/update")
    public boolean update(Admin admin) {
        return adminService.update(admin);
    }
    @PostMapping("/del")
    public boolean del(Integer id) {
        return adminService.del(id);
    }
}
